<template>
  <div>
    <el-dialog v-loading="loading" :close-on-click-modal="false" :close-on-press-escape="false" :title="'消费记录'" :visible.sync="creditDialogVisible" width="1000px" append-to-body :before-close="close">

      <el-table v-loading="table_loading" :data="list" style="width: 100%;">
        <!--        <el-table-column label="ID" align="center" prop="id" />-->
        <el-table-column label="订单号" align="center" prop="order_no" />

        <el-table-column label="金额" align="center">
          <template slot-scope="scope">
            <span v-if="scope.row.is_increase === 0">-</span>{{ scope.row.amount }}
            <el-tag v-if="scope.row.is_refunded == 1" size="mini">已退款</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="变动" align="center" prop="is_sale">
          <template slot-scope="scope">
            <el-tag v-if="scope.row.transaction_type === 0" size="mini" type="danger">扣款</el-tag>
            <el-tag v-else size="mini">增加</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="授信剩余" align="center" prop="account_residue" />
        <el-table-column label="时间" align="center" prop="transaction_time" />
      </el-table>

      <pagination v-show="total>0" :total="total" :page.sync="queryParams.page" :limit.sync="queryParams.limit" @pagination="getList" />
    </el-dialog>
  </div>
</template>
<script>
import {
  addSyncQekjTask,
  dealSyncQekjTask,
  getCreditList,
  getTenantRemoteList,
  goodsTenantSync
} from '@/api/externalGoods'

export default {
  name: 'Credit',
  components: {},

  props: {
    creditDialogVisible: {
      type: Boolean
    }
  },
  data() {
    return {
      form: {
        type: 'all',
        cover: 0,
        section_goods_spus: []
      },
      loading: true,
      table_loading: true,
      percentagea: 0,
      list: [],
      radio: 0,
      total: 0,
      sy: 0,
      btnClickLoading: false,
      queryParams: {
        page: 1,
        limit: 10
      }
    }
  },
  watch: {
    'creditDialogVisible': function(newValue, oldValue) {
      if (newValue) {
        this.getList()
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    close() {
      // this.btnClickLoading = false
      // this.percentagea = 0
      this.$emit('update:creditDialogVisible', false)
    },
    getList() {
      this.table_loading = true
      getCreditList(this.queryParams).then(res => {
        // console.log(res)
        if (res.code === 10000) {
          this.list = res.data
          this.total = res.count
          this.table_loading = false
        }
      })
    }
  }
}
</script>

